import request from '@/utils/request';
import {AxiosPromise} from 'axios';
import {SwiperVO, SwiperForm, SwiperQuery} from '@/api/infra/swiper/types';

/**
 * 查询轮播图列表
 * @param query
 * @returns {*}
 */

export const listSwiper = (query?: SwiperQuery): AxiosPromise<SwiperVO[]> => {
    return request({
        url: '/infra/swiper/list',
        method: 'get',
        params: query
    });
};

/**
 * 查询轮播图详细
 * @param swiperId
 */
export const getSwiper = (swiperId: string | number): AxiosPromise<SwiperVO> => {
    return request({
        url: '/infra/swiper/' + swiperId,
        method: 'get'
    });
};

/**
 * 新增轮播图
 * @param data
 */
export const addSwiper = (data: SwiperForm) => {
    return request({
        url: '/infra/swiper',
        method: 'post',
        data: data
    });
};

/**
 * 修改轮播图
 * @param data
 */
export const updateSwiper = (data: SwiperForm) => {
    return request({
        url: '/infra/swiper',
        method: 'put',
        data: data
    });
};

/**
 * 删除轮播图
 * @param swiperId
 */
export const delSwiper = (swiperId: string | number | Array<string | number>) => {
    return request({
        url: '/infra/swiper/' + swiperId,
        method: 'delete'
    });
};

/**
 * 状态修改
 * @param swiperId
 * @param status
 */
export const changeStatus = (swiperId: number | string, status: string) => {
    const data = {
        swiperId,
        status
    };
    return request({
        url: '/infra/swiper/changeStatus',
        method: 'put',
        data: data
    });
};
